﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Filters;

namespace FitterTest.Filters
{
    public class CtmAuthorizationFilter : Attribute, IAuthorizationFilter
    {
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            //var queryStr = context.HttpContext.Request.QueryString;

            var authorizationService = context.HttpContext.RequestServices.GetService<IAuthorizationService>();

            //// 创建一个授权要求（如果还没有的话）  
            //var myRequirement = new MyCustomRequirement(); // 自定义要求类 

            //// 创建一个包含用户、要求和资源的授权上下文  
            //var authContext = new AuthorizationHandlerContext(new[] { myRequirement }, context.HttpContext.User, null);

            //// 调用授权服务来评估授权上下文  
            //authorizationService.AuthorizeAsync(authContext).GetAwaiter().GetResult();
            return;
        }
    }
}
